/**
 * 果篮抽奖界面
 */
class FruitBasketUI extends UIBase{
    private item_1:FruitBasketItem;
    private item_2:FruitBasketItem;
    private item_3:FruitBasketItem;
    private btn_back:BaseButton;
    public isCanTouch:boolean = true;
    private img_light_1:eui.Image;
    private img_light_2:eui.Image;
    private list;
    constructor()
    {
        super('FruitBasketView');
    }

    public init()
    {
        super.init(true);
        this.requestInfo();
    }

    public requestInfo()
    {
        let data = {
            version:GameConst.version
        }
        
        HttpManager.instance().sendPost(GameConst.httpUrl + 'warriorother/lucky_card', StringUtil.jsonToHttpPostString(data), (e)=>{
            let data = JSON.parse(e)
            if(data && data.data)
            {
                this.list = data.data;
                this.initUI();
            }
        }, this);
    }

    public initUI()
    {
        let list = this.list;
        for(let i=1;i<=3;i++)
        {
            let item = this['item_'+i] as FruitBasketItem;
            item.initUI(list[i-1]);
        }
    }

    public addEvent()
    {   
        this.btn_back.addTapHandler(this.close, this);
    }

    public close()
    {
        this.remove(4)
    }

    public removeEvent()
    {
        this.btn_back.removeTapHandler();
    }

    public clear()
    {
        super.clear();
        this.isCanTouch = null;
        this.list = null;
    }
}   